<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="f"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
	<div class="container">
		<div class="col-lg-2"></div>
		<div class="col-lg-7">
			<f:form modelAttribute="employee" action="user/save" method="POST"
				id="insert">
				<br>
				<br> LastName
					<f:input path="lastName" id="lastName" />
				<br>
				<br> Email:
					<f:input path="email" />
				<br>
				<br> Birth:
					<f:input path="birth" />
					
				<br> 
				<br> Department:
					<f:select path="department.id" items="${departments }"
					itemLabel="departmentName" itemValue="id"></f:select>
				<br>
				<br> Actor:
					<f:select path="actor.id" items="${actors }" itemLabel="name"
					itemValue="id"></f:select>
				<br>
				 <br>
				 <!-- 
				  <input type="button" value="Submit" id="bt_insert" data-addtab="list" ajax='true' method="post" title="员工信息" parentid="insert"/>
			-->
			</f:form>
		</div>
		</div>
	

<script type="text/javascript">
	$(document).ready(
			function() {
				var isok = 0;
				$("#lastName").focusout(
						function() {

							$.when($.onlyByLastName($(this).val(), "isOnly"))
									.done(function(result) {
										if (result == "有") {
											isok = 1; //已经有相同记录
											//console.log(result);
										} else {
											isok = 0;
											//console.log(result);
										}
									});
						});
			//添加之前需要判定一下是完全符合条件
			//$("#bt_insert").click(function() {
				//console.log(isok);
				//if(isok != 0) {
					//	console.log("error");
				//	return false;
				//} else {
				//	$('#save').sumbit();
				//}
			//})

		});
	</script>
	</body>
</html>